import json
import requests

url = "http://127.0.0.1:8000"

# 测试1: @app.get("/items/{item_id}")
url_get = f"{url}/items/123?q=abcdef"
resp = requests.get(url_get)
print(resp.text)
print(resp.status_code)

# 测试2: @app.put("/items/{item_id}")
url_put = f"{url}/items/123"
head = {
    "Content-Type": "application/json",
    "accept": "application/json",
}
# 和 post结构体一致, class Item(BaseModel):
data = {
    "name": "123",
    "price": 123.0,
    "is_offer": True,
}
resp = requests.put(url_put, headers=head, data=json.dumps(data))
print(resp.text)
print(resp.status_code)
